//
//  VideoCell.m
//  New
//
//  Created by 才诗琦 on 16/1/21.
//  Copyright © 2016年 www.lanou3g.com. All rights reserved.
//


#define animationDuration  0.3
#import "VideoCell.h"



@implementation VideoCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        //图片
        self.imagView = [[UIImageView alloc] init];
        self.imagView.layer.cornerRadius = 5;
        _imagView.clipsToBounds = YES;
        [self.contentView addSubview:_imagView];
        [_imagView release];
        

        
              //标题
        self.titleLabel = [[UILabel alloc] init];
        _titleLabel.font = [UIFont systemFontOfSize:19];
        [self.contentView addSubview:_titleLabel];
        [_titleLabel release];
        //描述
        
        self.descriptionLabel = [[UILabel alloc] init];
        _descriptionLabel.textColor = [UIColor grayColor];
        [self.contentView addSubview:_descriptionLabel];
        [_descriptionLabel release];
        
        
        //时长图片
        self.timeView = [[UIImageView alloc] init];
        [_timeView setImage:[UIImage imageNamed:@"shizhong"]];
        [self.contentView addSubview:_timeView];
        [_timeView release];
        //时长
        self.timeLabel = [[UILabel alloc] init];
        [self.contentView addSubview:_timeLabel];
        [_timeLabel release];
        
        //点击量
        self.playCountLabel = [[UILabel alloc] init];
        [self.contentView addSubview:_playCountLabel];
        [_playCountLabel release];
        
        //播放图片
        self.playView = [[UIImageView alloc] init];

        [_playView setImage:[UIImage imageNamed:@"bofang2"]];
        [self.contentView addSubview:_playView];
        [_playView release];
        
        //评论
        self.pinglunButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [_pinglunButton setImage:[UIImage imageNamed:@"pinglun1.png"] forState:UIControlStateNormal];
        [self.contentView addSubview:_pinglunButton];
        //播放按钮
//
        self.playButton = [UIButton buttonWithType:UIButtonTypeCustom];
//
        self.playButton.backgroundColor = [UIColor redColor];
        [self.contentView addSubview:_playButton];
//        NSLog(@"%@", self.str);

//
  }
//
    return self;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    
    
    self.imagView.frame = CGRectMake(15, 80, self.contentView.frame.size.width - 20, 200);
    // layer需要设置大小
   
    self.titleLabel.frame = CGRectMake(10, 10, self.contentView.frame.size.width - 20, 40);
    self.descriptionLabel.frame = CGRectMake(10, 50, self.contentView.frame.size.width - 20, 30);
    
    self.timeView.frame = CGRectMake(10, 280, 30, 30);
    self.timeLabel.frame = CGRectMake(40, 280, 60, 30);
    
    self.playView.frame = CGRectMake(100, 284, 22, 22);
    self.playCountLabel.frame = CGRectMake(130, 280, 60, 30);
   }



//创建AVplayer
//-(void)creatAVplayer
//{
//    //创建视频对象
//    self.playerItem = [AVPlayerItem playerItemWithURL:[NSURL URLWithString:_str]];
//    self.player = [AVPlayer playerWithPlayerItem:_playerItem];
//    
//    self.playerLayer = [AVPlayerLayer playerLayerWithPlayer:_player];
//    _playerLayer.videoGravity = AVLayerVideoGravityResizeAspectFill;
//    [_playerView.layer insertSublayer:_playerLayer atIndex:0];
//    [_player play];
//    //创建中间视图
//    self.middleView.frame = CGRectMake(_playerView.frame.size.width / 5 * 2, _playerView.frame.size.height / 3 * 1, _playerView.frame.size.width / 7, _playerView.frame.size.width / 7);
//    //播放按钮
//    _playBtn.frame = CGRectMake(0, 0, _middleView.frame.size.width, _middleView.frame.size.height);
//    [_playBtn setBackgroundImage:[UIImage imageNamed:@"iconfont-shipin"] forState:UIControlStateNormal];
//    [_playBtn addTarget:self action:@selector(playAction:) forControlEvents:UIControlEventTouchUpInside];
//    [_middleView addSubview:_playBtn];
//    //创建底部视图
//    self.buttomView.frame = CGRectMake(0, _playerView.frame.size.height / 7 * 6, _playerView.frame.size.width, _playerView.frame.size.height / 10);
//    //滑动进度条
//    _slider.frame = CGRectMake(0, 0, _buttomView.frame.size.width / 4 * 3, _buttomView.frame.size.height);
//    [_slider addTarget:self action:@selector(sliderAction:) forControlEvents:UIControlEventValueChanged];
//    
//    //时间显示
//    _timLable.frame = CGRectMake(_slider.frame.size.width, _slider.frame.origin.y, _buttomView.frame.size.width / 4 , _slider.frame.size.height);
//    _timLable.textColor = [UIColor whiteColor];
//    _timLable.font = [UIFont systemFontOfSize:10];
//    
//}
//

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
